class Admin::SessionsController < Admin::BaseController
	layout 'login'
	skip_filter :authenticate
	
  def new
  end
  
  def create
    admin_user = AdminUser.authenticate(params[:admin_name],params[:password])
    if admin_user
      admin_user.update_attribute("last_login_time",Time.now)
      if admin_user.status == 1 || admin_user.status.blank?
        flash[:notice] = "成功登录!"
        session[:admin_user] = admin_user.id
        redirect_to "/admin_xx2"
      elsif admin_user.status == -2
        flash[:error] = "用户已被删除!"
        redirect_to login_path
      end
    else
      flash[:error] = "帐号密码不正确!"
      redirect_to login_path
    end
  end

  def destroy
    session[:admin_user] = nil
    redirect_to '/admin_xx2'
  end

end
